//
//  GWCategoriesModel.m
//  GiftWanted
//
//  Created by lanou on 15/11/10.
//  Copyright © 2015年 陈文杰. All rights reserved.
//

#import "GWCategoriesModel.h"
#import "GWSubcategoriesModel.h"

@implementation GWCategoriesModel
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if ([key isEqualToString:@"id"]) {
        _id_s = value;
    }
}

- (instancetype)init {
    self = [super init];
    if (self) {
        _subcategories = [NSMutableArray arrayWithCapacity:0];
    }
    return self;
}

- (void)setValue:(id)value forKey:(NSString *)key {
    if ([key isEqualToString:@"subcategories"]) {
        for (NSDictionary *dict in value) {
            GWSubcategoriesModel *model = [[GWSubcategoriesModel alloc] init];
            [model setValuesForKeysWithDictionary:dict];
            [_subcategories addObject:model];
        }
    } else {
        [super setValue:value forKey:key];
    }
}

@end
